Skip to content

fix: Only treat frozen Numeric defaults as immutable - #160

Merged
jterapin merged 1 commit into
mainfrom
correctness-hygiene
Aug 17, 2026
Merged

fix: Only treat frozen Numeric defaults as immutable#160
jterapin merged 1 commit into
mainfrom
correctness-hygiene

Conversation

@jterapin

Copy link
Copy Markdown
Contributor

Issue #:

Description of changes:
The _immutable? fast path added in #159 used value.is_a?(Numeric), which matches any Numeric subclass. A mutable custom Numeric subclass used as a default_value was therefore returned by identity and shared across every record in the process, so mutating it on one record leaked into the others.

This guards the numeric branch with frozen?: only genuinely immutable numerics skip the deep copy. Every stdlib numeric is already frozen, so they stay on the fast path and the #159 optimization is preserved; an unfrozen mutable subclass falls back to the existing deep copy.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.


Written with AI assistance and reviewed by jterapin

@jterapin
jterapin merged commit ed729ea into main Aug 17, 2026
13 checks passed
@jterapin
jterapin deleted the correctness-hygiene branch August 17, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants